#pragma once

class TerrainUI
{
	Dialog* m_dialog;
	ShaderUI* m_shaderUI;
	DialogText* m_textRadius;
	DialogText* m_intensity;
	Scrollbar<TerrainUI>* m_barRadius;
	Scrollbar<TerrainUI>* m_barIntensity;

	RadioButton<TerrainUI>* m_flatButton;
	RadioButton<TerrainUI>* m_smoothButton;
	RadioButton<TerrainUI>* m_linearButton;
	RadioButton<TerrainUI>* m_quadButton;

	RadioButton<TerrainUI>* m_heightButton;
	RadioButton<TerrainUI>* m_flattButton;
	RadioButton<TerrainUI>* m_blurButton;

	Checkbox<TerrainUI>* m_pAlignObjs;

	void ScrollRadius(Scrollbar<TerrainUI>* pBar, ui32 value);
	void ScrollIntensity(Scrollbar<TerrainUI>* pBar, ui32 value);
	void TerrainTypeChange(RadioButton<TerrainUI>* pButton, bool checked);
	void TerrainModeChange(RadioButton<TerrainUI>* pButton, bool checked);
	void AlignCheck(Checkbox<TerrainUI>*, ui32) { }
	void ShowShaderProc(UIButton<TerrainUI>*)
	{
		m_shaderUI->Show();
	}

public:
	TerrainUI();
	void SetRadius(float radius)
	{
		//ui32 value = (ui32)floor(4.0f * radius / UNITSIZE - 4.0f);
		m_barRadius->SetValue(ui32(radius * 10));
		char msg[255];
		sprintf_s<255>(msg, "Radius: %.02f", radius);
		m_textRadius->szText = msg;
	}
	
	void SetIntensity(float intensity)
	{
		ui32 value = (ui32)floor(intensity / 0.3f);
		m_barIntensity->SetValue(value);
		char msg[255];
		sprintf_s<255>(msg, "%s: %.01f", sLocale.GetLocale(2, "Intensity").c_str(), intensity);
		m_intensity->szText = msg;
	}

	void SetType(ui32 type)
	{
		if(type == 0)
		{
			m_flatButton->Check();
			m_smoothButton->Uncheck();
			m_linearButton->Uncheck();
			m_quadButton->Uncheck();
		}
		if(type == 2)
		{
			m_smoothButton->Check();
			m_flatButton->Uncheck();
			m_linearButton->Uncheck();
			m_quadButton->Uncheck();
		}
		if(type == 1)
		{
			m_linearButton->Check();
			m_flatButton->Uncheck();
			m_smoothButton->Uncheck();
			m_quadButton->Uncheck();
		}
		if(type == 3)
		{
			m_quadButton->Check();
			m_flatButton->Uncheck();
			m_linearButton->Uncheck();
			m_smoothButton->Uncheck();
		}
	}

	void Toggle() { m_dialog->m_visible = !m_dialog->m_visible; }

	bool IsAlignEnabled() { return m_pAlignObjs->m_state != 0; }

	void Update()
	{
		if(!m_dialog->m_visible)
			m_shaderUI->Hide();
	}
};